package com.hippomeetsskunk.savanna.types.world;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;

import org.apache.log4j.Logger;


public class World {

	private static Logger logger = Logger.getLogger(World.class);
	
	private static World world;
	private Time time = new Time();
	private Collection<Region> regions = new HashSet<Region>();
	
	private World(){
	}
	
	public void startDay(){
		// TODO use events to trigger?
		time.startDay();
		logger.info("**** " + time + " ****");
		for(Region r : regions){
			r.startDay(time);
		}
	}

	public Time getTime(){
		return time;
	}
	
	public void add(Region region){
		this.regions.add(region);
	}
	
	public static World getInstance(){
		if (world == null){
			world = new World();
		}
		return world;
	}
	
	public Collection<Region> getRegions(){
		return Collections.unmodifiableCollection(regions);
	}
}
